/********************************全局变量-START--rlx--2017.08.25*****************************************/
//异步请求接口路径
var WEB_URL = location.origin;
var PAI_PATH = location.origin;
//运行：0=微信环境，1=WEB调试环境
var ACTION = 1;
//当前URL中需要过滤掉的URL参数
var URL_OUT_KEY = new Array();
URL_OUT_KEY.push("user_token");
URL_OUT_KEY.push("channel_info");
URL_OUT_KEY.push("jsapi_ticket");
URL_OUT_KEY.push("appId");
URL_OUT_KEY.push("from");
URL_OUT_KEY.push("isappinstalled");
/********************************全局变量-END*****************************************/

/********************************token-START--rlx--2017.08.25*****************************************/
var Header = {
  WebTokenCheck: function (thisPage) {
    if (thisPage != null) {
      //alert("WebTokenCheck开始:" + window.location.href);
      //先取url里面的user_token
      var user_token = getUrlParam("user_token");
      //刚从认证过来的--更新本地数据
      if (user_token != "") {
        //alert("存user_token:" + user_token);
        localStorage.user_token = user_token;
      }
    }
    //本地数据
    user_token = getLocalStorage("user_token");
    //URL的渠道信息
    var channel_info = getUrlParam("channel_info");
    if (channel_info != "") {
      localStorage.channel_info = channel_info;
    }
    //判断是否重新请求获取token----（1.新渠道进入系统，2.本地没有token）
    if (channel_info != "" || user_token == "") {
      Header.post_token(user_token);
      //alert("channel_info:" + channel_info);
      //alert("user_token:" + user_token);
      //alert("channel_info != '' || user_token == '' post_token and return WebTokenCheck");
      return;
    }
    //如果ticket验证失败则，肯定需要重新走一次认证流程，则把user_token赋值为空(必须要先保证user_token无误才进行ticket验证)
    if (!Header.JsApiTicketCheck()) {
      user_token = "";
      Header.post_token(user_token);
      //alert("!Header.JsApiTicketCheck() post_token and return WebTokenCheck");
      return;
    }
    if (window.location.href != GetRedirectUri()) {
      //alert("跳转GetRedirectUri()：" + GetRedirectUri());
      //alert("window.location.href：" + window.location.href);
      location.href = GetRedirectUri();
      return;
    }
    //验证完所有参数，在进行JSSDK认证
    Header.Init(thisPage);
  },
  post_token: function (user_token) {
    //重新请求用户数据
    //获取客户端类型
    var web_type = GetWebType();
    var redirect_uri = GetRedirectUri();
    var channel_info = getLocalStorage("channel_info");
    method.PostApiUrl(
      "WeiXin/CheckToken",
      {
        channel_info: channel_info,
        user_token: user_token,
        web_type: web_type,
        redirect_uri: redirect_uri,
      },
      function (data) {
        //判断是否还需要走认证页面
        if (data.Data.is_oauth2 == 1) {
          //alert("跳转oauth2_url：" + data.Data.oauth2_url);
          location.href = data.Data.oauth2_url;
        } else {
          localStorage.user_token = data.Data.user_token;
          //alert("跳转redirect_uri：" + redirect_uri);
          location.href = redirect_uri;
        }
      }
    );
  },
  JsApiTicketCheck: function () {
    //只有在微信端打开才走jsapi相关的方法
    if (GetWebType() != "weixin") {
      return true;
    }
    var jsapi_ticket = getUrlParam("jsapi_ticket");
    if (jsapi_ticket != "") {
      localStorage.jsapi_ticket = jsapi_ticket;
      localStorage.appId = getUrlParam("appId");
    }
    //本地数据
    var this_jsapi_ticket = getLocalStorage("jsapi_ticket");
    var this_appId = getLocalStorage("appId");
    //判断本地jsapi票据是否存在
    if (this_jsapi_ticket == "" || this_appId == "") {
      console.log(111);
      return false;
    }
    return true;
  },
  Init: function (thisPage) {
    if (ACTION == 1) {
      thisPage.main();
      return;
    }
    //需要注册jssdk
    //jsapi_ticket和appId已经通过JsApiTicketCheck验证过了
    WeiXin.config(getLocalStorage("jsapi_ticket"), getLocalStorage("appId"));
    WeiXin.result(thisPage);
  },
};
/********************************token-END*****************************************/

/********************************微信JSSDK注册及分享接口-START--rlx--2017.08.25*****************************************/
var WeiXin = {
  //配置
  config: function (jsapi_ticket, appId) {
    var timestamp = Date.parse(new Date()) / 1000;
    var nonceStr = randomString(9);
    //生成签名
    var signature_str = "jsapi_ticket=" + jsapi_ticket;
    signature_str += "&noncestr=" + nonceStr;
    signature_str += "&timestamp=" + timestamp;
    signature_str += "&url=" + window.location.href;
    //alert("signature_str:" + signature_str);
    var signature = $.sha1(signature_str);
    //获取JSSDK中的配置签名
    wx.config({
      debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
      appId: appId, // 必填，公众号的唯一标识
      timestamp: timestamp, // 必填，生成签名的时间戳
      nonceStr: nonceStr, // 必填，生成签名的随机串
      signature: signature, // 必填，签名，见附录1
      jsApiList: [
        "checkJsApi",
        "onMenuShareTimeline",
        "onMenuShareAppMessage",
        "onMenuShareQQ",
        "onMenuShareWeibo",
        "hideMenuItems",
        "showMenuItems",
        "hideAllNonBaseMenuItem",
        "showAllNonBaseMenuItem",
        "translateVoice",
        "startRecord",
        "stopRecord",
        "onRecordEnd",
        "playVoice",
        "pauseVoice",
        "stopVoice",
        "uploadVoice",
        "downloadVoice",
        "chooseImage",
        "previewImage",
        "uploadImage",
        "downloadImage",
        "getNetworkType",
        "openLocation",
        "getLocation",
        "hideOptionMenu",
        "showOptionMenu",
        "closeWindow",
        "scanQRCode",
        "chooseWXPay",
        "openProductSpecificView",
        "addCard",
        "chooseCard",
        "openCard",
      ], // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
    });
  },
  //验证结果
  result: function (thisPage) {
    wx.ready(function () {
      //隐藏所有非基础功能按钮
      wx.hideAllNonBaseMenuItem();
      var thisUrl = GetRedirectUri(); //会过滤掉特殊参数
      method.PostApiUrl("WeiXin/ShareInfo", { ThisUrl: thisUrl }, function (
        data
      ) {
        window.title = data.Data.title;
        window.desc = data.Data.desc;
        window.img = data.Data.img;
        window.link = data.Data.link; // 分享链接
        window.out_link = data.Data.out_link; //分享到外部浏览器的链接
        //批量显示功能按钮接口
        var menuList = [
          "menuItem:share:appMessage",
          "menuItem:share:timeline",
          "menuItem:copyUrl",
        ];
        wx.showMenuItems({
          menuList: menuList, // 要显示的菜单项，所有menu项见附录3
        });
        //分享到朋友圈
        wx.onMenuShareTimeline({
          title: title, // 分享标题
          link: link, // 分享链接
          imgUrl: img, // 分享图标
          success: function () { },
          cancel: function () {
            // 用户取消分享后执行的回调函数
          },
        });
        //分享给朋友
        wx.onMenuShareAppMessage({
          title: title, // 分享标题
          desc: desc, // 分享描述
          link: link, // 分享链接
          imgUrl: img, // 分享图标
          type: "", // 分享类型,music、video或link，不填默认为link
          dataUrl: "", // 如果type是music或video，则要提供数据链接，默认为空
          success: function () { },
          cancel: function () {
            // 用户取消分享后执行的回调函数
          },
        });
        wx.getLocation({
          type: "gcj02", // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
          success: function (res) {
            if (res.longitude != 0 || res.latitude != 0) {
              localStorage.longitude = res.longitude;
              localStorage.latitude = res.latitude;
            }
          },
        });
        //执行页面主函数
        thisPage.main();
      });
    });
    wx.error(function (res) {
      localStorage.removeItem("user_token");
      Header.WebTokenCheck(null);
      // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。
    });
  },
};
/********************************微信分享接口-END*****************************************/

/*******************************微信支付-START--rlx--2017.08.25*****************************************/
//调用微信JS api 支付
function jsApiCall (wxJsApiParam, callBackUrl, callBackError) {
  WeixinJSBridge.invoke(
    "getBrandWCPayRequest",
    JSON.parse(wxJsApiParam), //josn串
    function (res) {
      WeixinJSBridge.log(res.err_msg);
      if (res.err_msg == "get_brand_wcpay_request:ok") {
        layer.open({
          content: "支付成功",
          shadeClose: false,
          time: 1, //1秒后自动关闭
        });
        setTimeout(function () {
          location.href = callBackUrl;
        }, 1100);
      } else {
        //上报支付失败
        callBackError();
      }
    }
  );
}
function callpay (wxJsApiParam, callBackUrl, callBackError) {
  if (typeof WeixinJSBridge == "undefined") {
    if (document.addEventListener) {
      document.addEventListener(
        "WeixinJSBridgeReady",
        jsApiCall(wxJsApiParam, callBackUrl, callBackError),
        false
      );
    } else if (document.attachEvent) {
      document.attachEvent(
        "WeixinJSBridgeReady",
        jsApiCall(wxJsApiParam, callBackUrl, callBackError)
      );
      document.attachEvent(
        "onWeixinJSBridgeReady",
        jsApiCall(wxJsApiParam, callBackUrl, callBackError)
      );
    }
  } else {
    jsApiCall(wxJsApiParam, callBackUrl, callBackError);
  }
}
/********************************微信支付-END*****************************************/

/********************************common-START--rlx--2017.08.25*****************************************/
//layer加载中
function loadingOpen () {
  try {
    var i = layer.open({
      type: 2,
      shadeClose: false,
    });
    return i;
  } catch (e) {
    return 0;
  }
}
function loadingClose (i) {
  try {
    layer.close(i);
  } catch (e) { }
}

//获取用户端类型
function GetWebType () {
  var browser = {
    versions: (function () {
      var u = navigator.userAgent,
        app = navigator.appVersion;
      return {
        //移动终端浏览器版本信息
        trident: u.indexOf("Trident") > -1, //IE内核
        presto: u.indexOf("Presto") > -1, //opera内核
        webKit: u.indexOf("AppleWebKit") > -1, //苹果、谷歌内核
        gecko: u.indexOf("Gecko") > -1 && u.indexOf("KHTML") == -1, //火狐内核
        mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
        ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
        android: u.indexOf("Android") > -1 || u.indexOf("Linux") > -1, //android终端或uc浏览器
        iPhone: u.indexOf("iPhone") > -1, //是否为iPhone或者QQHD浏览器
        iPad: u.indexOf("iPad") > -1, //是否iPad
        webApp: u.indexOf("Safari") == -1, //是否web应该程序，没有头部与底部
      };
    })(),
    language: (navigator.browserLanguage || navigator.language).toLowerCase(),
  };
  if (browser.versions.mobile) {
    //判断是否是移动设备打开。browser代码在下面
    var ua = navigator.userAgent.toLowerCase(); //获取判断用的对象
    //if (browser.versions.ios) {
    //    return ("ios");
    //}
    //if (browser.versions.android) {
    //    return ("android");
    //}
    if (ua.match(/MicroMessenger/i) == "micromessenger") {
      return "weixin";
    }
    if (ua.match(/WeiBo/i) == "weibo") {
      return "weibo";
    }
    if (ua.match(/QQ/i) == "qq") {
      return "qq";
    }
    return "mobile";
  } else {
    var ua = navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == "micromessenger") {
      return "weixin";
    } else {
      return "pc";
    }
  }
}

//获取固定长度的随机字符串
function randomString (len) {
  len = len || 32;
  var $chars =
    "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678"; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
  var maxPos = $chars.length;
  var pwd = "";
  for (i = 0; i < len; i++) {
    pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
  }
  return pwd;
}

//获取localStorage,异常会返回空字符串
function getLocalStorage (name) {
  var _this_value;
  try {
    if (localStorage[name] == undefined || localStorage[name] == null) {
      throw "";
    }
    _this_value = localStorage[name]; //读取本地localStorage
  } catch (e) {
    _this_value = ""; //读取本地localStorage可能会报错
  }
  return _this_value;
}
/********************************common-END*****************************************/

/********************************异步请求接口-START--rlx--2017.08.25*****************************************/
var Request = function () { };
var method = new Request();

Request.prototype.get_token = function () {
  return getLocalStorage("user_token");
};
//POST请求
/*
action->请求的方法名称
json->请求的json数据(json格式)
callback->回调函数
*/
Request.prototype.PostApiUrl = function (action, json, _callback, isLoadLayer) {
  //isLoadLayer控制是否弹出加载loading层
  if (isLoadLayer) {
    var layerIndex = loadingOpen();
  }
  try {
    var url = PAI_PATH + action;
    var params = {
      Token: method.get_token(),
      Data: json,
    };
    $.ajax({
      type: "POST",
      url: url,
      data: JSON.stringify(params),
      dataType: "json",
      contentType: "application/json",
      success: function (data) {
        if (isLoadLayer) {
          loadingClose(layerIndex);
        }
        if (data.ErrorCode == "0") {
          _callback(data);
        } else {
          Error(data);
        }
      },
    });
  } catch (e) {
    //loadingClose(layerIndex);
    layer.open({
      content: "服务器异常，请刷新后重试",
      time: 2, //2秒后自动关闭
    });
  }
};

/********************************异步请求接口-END*****************************************/

/********************************错误处理-START--rlx--2017.08.25*****************************************/
function Error (data) {
  if (data.ErrorCode == 100 || data.ErrorCode == 110) {
    localStorage.removeItem("user_token");
    Header.WebTokenCheck(null);
    return;
  }
  if (data.ErrorCode == 610) {
    localStorage.back_url = GetRedirectUri();
    location.href = "usersLogin.html";
    return;
  }
  if (data.ErrorCode == 620) {
    localStorage.back_url = GetRedirectUri();
    location.href = "usersRegister.html";
    return;
  }
  if (data.ErrorCode == 130) {
    if (!Window.QRCODELAYER) {
      Window.QRCODELAYER = layer.open({
        title: ["请扫描二维码关注", "background-color: #FF4351; color:#fff;"],
        content: '<static src="' + data.Msg + '" style="width:80%;"/>',
        shadeClose: false,
      });
    }
    return;
  }

  // layer.open({
  //     content: data.Msg,
  //     time: 2 //2秒后自动关闭
  // });
}
/********************************错误处理-END*****************************************/

/********************************运算方法-START--rlx--2017.08.25*****************************************/
//JS里面的算法全都用此方法实现，避免失真
//乘法
function accMul (arg1, arg2) {
  var m = 0,
    s1 = arg1.toString(),
    s2 = arg2.toString();
  try {
    m += s1.split(".")[1].length;
  } catch (e) { }
  try {
    m += s2.split(".")[1].length;
  } catch (e) { }
  return (
    (Number(s1.replace(".", "")) * Number(s2.replace(".", ""))) /
    Math.pow(10, m)
  );
}
//加法
function accAdd (arg1, arg2) {
  var r1, r2, m;
  try {
    r1 = arg1.toString().split(".")[1].length;
  } catch (e) {
    r1 = 0;
  }
  try {
    r2 = arg2.toString().split(".")[1].length;
  } catch (e) {
    r2 = 0;
  }
  m = Math.pow(10, Math.max(r1, r2));
  return (arg1 * m + arg2 * m) / m;
}
//减法
function Subtr (arg1, arg2) {
  var r1, r2, m, n;
  try {
    r1 = arg1.toString().split(".")[1].length;
  } catch (e) {
    r1 = 0;
  }
  try {
    r2 = arg2.toString().split(".")[1].length;
  } catch (e) {
    r2 = 0;
  }
  m = Math.pow(10, Math.max(r1, r2));
  n = r1 >= r2 ? r1 : r2;
  return ((arg1 * m - arg2 * m) / m).toFixed(n);
}
/********************************运算方法-END*****************************************/

/********************************文本内容两端对齐的方法*****************************************/
//$container : 文本所在容器的jQuery对象
function textContentAlignCenter ($container) {
  $container.css({ "text-align": "justify", "letter-spacing": "-0.15em" });
  $container.html($container.html().split("").join(" "));
}

/********************************时间相关方法-START--rlx--2017.08.25*****************************************/
Date.prototype.Format = function (fmt) {
  var o = {
    "M+": this.getMonth() + 1, //月份
    "d+": this.getDate(), //日
    "H+": this.getHours(), //小时
    "m+": this.getMinutes(), //分
    "s+": this.getSeconds(), //秒
    "q+": Math.floor((this.getMonth() + 3) / 3), //季度
    S: this.getMilliseconds(), //毫秒
  };
  if (/(y+)/.test(fmt))
    fmt = fmt.replace(
      RegExp.$1,
      (this.getFullYear() + "").substr(4 - RegExp.$1.length)
    );
  for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt))
      fmt = fmt.replace(
        RegExp.$1,
        RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)
      );
  return fmt;
};
/********************************时间相关方法-END*****************************************/

/********************************UrlParse-START--rlx--2016.12.27*****************************************/
/**第一种方法：获取url的参数**/
function getUrlParam (name) {
  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
  var r = window.location.search.substring(1).match(reg); //匹配目标参数
  if (r != null) return unescape(r[2]);
  return ""; //返回参数值
}

/**第二种方法：获取url的参数**/
UrlParse = function () {
  this.host = location.host;
  this.url = location.herf;
  this.hash = location.hash;
  this.port = location.port;
  this.script_name = location.pathname;
  this.quartyString = location.search;
  this.protocol = location.protocol;
  this.GET = this.parseArguement();
};
UrlParse.prototype = {
  parseArguement: function () {
    var pos;
    var arg = new Object();
    var quire = location.search.substring(1);
    var pair = quire.split("&");
    if (pair.length > 0) {
      for (var i = 0; i < pair.length; i++) {
        pos = pair[i].indexOf("=");
        if (pos == -1) continue;
        argName = pair[i].substring(0, pos);
        argValue = pair[i].substring(pos + 1);
        arg[argName] = argValue;
      }
    } else {
      de = quire.indexOf("=");
      if (de != -1) {
        argName = pair[i].substring(0, de);
        argValue = pair[i].substring(de + 1);
        arg[argName] = argValue;
      }
    }
    return arg;
  },
};

//获取当前URL的实际链接----需要过滤掉不能当做回调url的参数
function GetRedirectUri () {
  var this_url = location.origin + location.pathname; //不带参数的url

  var Url = new UrlParse();

  for (key in Url.GET) {
    if (URL_OUT_KEY.indexOf(key) == -1) {
      if (this_url.indexOf("?") == -1) {
        this_url += "?" + key + "=" + Url.GET[key];
      } else {
        this_url += "&" + key + "=" + Url.GET[key];
      }
    }
  }
  return this_url;
}
/********************************UrlParse--END*****************************************/

/********************************SHA1加密算法-START--rlx--2017.08.25*****************************************/
(function ($) {
  var rotateLeft = function (lValue, iShiftBits) {
    return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
  };

  var lsbHex = function (value) {
    var string = "";
    var i;
    var vh;
    var vl;
    for (i = 0; i <= 6; i += 2) {
      vh = (value >>> (i * 4 + 4)) & 0x0f;
      vl = (value >>> (i * 4)) & 0x0f;
      string += vh.toString(16) + vl.toString(16);
    }
    return string;
  };

  var cvtHex = function (value) {
    var string = "";
    var i;
    var v;
    for (i = 7; i >= 0; i--) {
      v = (value >>> (i * 4)) & 0x0f;
      string += v.toString(16);
    }
    return string;
  };

  var uTF8Encode = function (string) {
    string = string.replace(/\x0d\x0a/g, "\x0a");
    var output = "";
    for (var n = 0; n < string.length; n++) {
      var c = string.charCodeAt(n);
      if (c < 128) {
        output += String.fromCharCode(c);
      } else if (c > 127 && c < 2048) {
        output += String.fromCharCode((c >> 6) | 192);
        output += String.fromCharCode((c & 63) | 128);
      } else {
        output += String.fromCharCode((c >> 12) | 224);
        output += String.fromCharCode(((c >> 6) & 63) | 128);
        output += String.fromCharCode((c & 63) | 128);
      }
    }
    return output;
  };

  $.extend({
    sha1: function (string) {
      var blockstart;
      var i, j;
      var W = new Array(80);
      var H0 = 0x67452301;
      var H1 = 0xefcdab89;
      var H2 = 0x98badcfe;
      var H3 = 0x10325476;
      var H4 = 0xc3d2e1f0;
      var A, B, C, D, E;
      var tempValue;
      string = uTF8Encode(string);
      var stringLength = string.length;
      var wordArray = new Array();
      for (i = 0; i < stringLength - 3; i += 4) {
        j =
          (string.charCodeAt(i) << 24) |
          (string.charCodeAt(i + 1) << 16) |
          (string.charCodeAt(i + 2) << 8) |
          string.charCodeAt(i + 3);
        wordArray.push(j);
      }
      switch (stringLength % 4) {
        case 0:
          i = 0x080000000;
          break;
        case 1:
          i = (string.charCodeAt(stringLength - 1) << 24) | 0x0800000;
          break;
        case 2:
          i =
            (string.charCodeAt(stringLength - 2) << 24) |
            (string.charCodeAt(stringLength - 1) << 16) |
            0x08000;
          break;
        case 3:
          i =
            (string.charCodeAt(stringLength - 3) << 24) |
            (string.charCodeAt(stringLength - 2) << 16) |
            (string.charCodeAt(stringLength - 1) << 8) |
            0x80;
          break;
      }
      wordArray.push(i);
      while (wordArray.length % 16 != 14) wordArray.push(0);
      wordArray.push(stringLength >>> 29);
      wordArray.push((stringLength << 3) & 0x0ffffffff);
      for (blockstart = 0; blockstart < wordArray.length; blockstart += 16) {
        for (i = 0; i < 16; i++) W[i] = wordArray[blockstart + i];
        for (i = 16; i <= 79; i++)
          W[i] = rotateLeft(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
        A = H0;
        B = H1;
        C = H2;
        D = H3;
        E = H4;
        for (i = 0; i <= 19; i++) {
          tempValue =
            (rotateLeft(A, 5) + ((B & C) | (~B & D)) + E + W[i] + 0x5a827999) &
            0x0ffffffff;
          E = D;
          D = C;
          C = rotateLeft(B, 30);
          B = A;
          A = tempValue;
        }
        for (i = 20; i <= 39; i++) {
          tempValue =
            (rotateLeft(A, 5) + (B ^ C ^ D) + E + W[i] + 0x6ed9eba1) &
            0x0ffffffff;
          E = D;
          D = C;
          C = rotateLeft(B, 30);
          B = A;
          A = tempValue;
        }
        for (i = 40; i <= 59; i++) {
          tempValue =
            (rotateLeft(A, 5) +
              ((B & C) | (B & D) | (C & D)) +
              E +
              W[i] +
              0x8f1bbcdc) &
            0x0ffffffff;
          E = D;
          D = C;
          C = rotateLeft(B, 30);
          B = A;
          A = tempValue;
        }
        for (i = 60; i <= 79; i++) {
          tempValue =
            (rotateLeft(A, 5) + (B ^ C ^ D) + E + W[i] + 0xca62c1d6) &
            0x0ffffffff;
          E = D;
          D = C;
          C = rotateLeft(B, 30);
          B = A;
          A = tempValue;
        }
        H0 = (H0 + A) & 0x0ffffffff;
        H1 = (H1 + B) & 0x0ffffffff;
        H2 = (H2 + C) & 0x0ffffffff;
        H3 = (H3 + D) & 0x0ffffffff;
        H4 = (H4 + E) & 0x0ffffffff;
      }
      var tempValue =
        cvtHex(H0) + cvtHex(H1) + cvtHex(H2) + cvtHex(H3) + cvtHex(H4);
      return tempValue.toLowerCase();
    },
  });
})(jQuery);
/********************************SHA1加密算法--END*****************************************/
